package com.zhl.Test;

public class TestDemo7 {
    public static void main(String[] args) {
        //判断101到200之间有多少个素数，并输出
         Countsu(101, 200);
    }

    public static void Countsu(int a, int b){
        int count = 0;
        for(int i =a; i<=b; i++){
            if(IsSu(i))
            {
                count++;
                System.out.println("该数是素数："+i);
            }
        }
        System.out.println("101到200之间有"+count+"个素数");
    }

    public static boolean IsSu(int num){
        for(int i=2; i<(num/2); i++){
            if(num%i == 0){
                return false;
            }
        }
        return true;
    }
}
